﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotNET4Study
{
    public static class InterfaceInheritStudy
    {
        public static void Execute()
        {
            Face f = new Face();

            Console.WriteLine("直接在类型上调用的结果{0}", f.Foo);

            IFace2 f2 = f;
            Console.WriteLine("将类型转化成父亲接口调用的结果{0}", f2.Foo);
            IFace2 f2a =(IFace2) f;
            Console.WriteLine("将类型转化成父亲接口调用的结果{0}", f2a.Foo);

            IFace1 f1 = f;
            Console.WriteLine("将类型转化成爷爷接口调用的结果{0}", f1.Foo);
            IFace1 f1a = (IFace1)f;
            Console.WriteLine("将类型转化成爷爷接口调用的结果{0}", f1a.Foo);
        }
    }

    public interface IFace1
    {
        string Foo { get; }
    }

    public interface IFace2 : IFace1
    {
        new int Foo { get; }
    }

    public class Face : IFace2
    {

        public int Foo
        {
            get { return 1; }
        }

        string IFace1.Foo
        {
            get { return "ssss"; }
        }
    }
}
